Subject: Joystick
From: [email-masked] (Son Huu Le)
To: [email-masked]
Date: Mon, 5 Jul 93 12:15:34 EST

Anyone want to access the joystick?

Son Le

PROC main()
DEF joypos, joyx, joyy, firebutton
/*
   $DFF00A (gameport 0) - %xxxxxxxx xxxxxxx fedcba98 76543210
   $DFF00C (gameport 1)

    left  - bit 9    up   - bit 8 xor bit 9,  Eor(bit 8,bit 9)
    right - bit 1    down - bit 0 xor bit 1,  Eor(bit 0,bit 1)

   $BFE001 (gameport fire) - %76543210

    fire gameport 0 - bit 7
    fire gameport 1 - bit 6      (zero-active, ie. 0=pressed)
*/
    WHILE CtrlC()=FALSE
        joypos:=Long($dff00a) AND $FFFF
        firebutton:=Char($bfe001)
        joyx:=joypos AND %11
        joyy:=Shr(joypos,8) AND %11
        IF ((joyx AND %10) = %10) THEN WriteF('right\t')
        IF ((joyy AND %10) = %10) THEN WriteF('left\t')
        IF (joyx = %01) OR (joyx = %10) THEN WriteF('down\t')
        IF (joyy = %01) OR (joyy = %10) THEN WriteF('up\t')

/*        IF Eor(joyx AND %01,Shr(joyx,1)) = 1 THEN WriteF('down\t')
        IF Eor(joyy AND %01,Shr(joyy,1)) = 1 THEN WriteF('up\t')
*/
        IF (firebutton AND %10000000) = 0 THEN WriteF('fire')
        WriteF('                  \b')
    ENDWHILE
ENDPROC